const { sequelize, DataTypes } = require('../utill/getSequelize')

// 定义中间表模型
const T_exam_questions_and_label = sequelize.define('T_exam_questions_and_label', {
  // 可以添加其他字段，例如关联表的主键
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  // 外键指向题目表的ID
  question_id: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  // 外键指向标签表的ID
  label_id: {
    type: DataTypes.INTEGER,
    allowNull: false
  }
});

// const { T_exam_label } = require('./t_exam_label')
// const { T_exam_question } = require('./t_exam_question')

// // 定义多对多关系
// T_exam_question.belongsToMany(T_exam_label, { through: 'T_exam_questions_and_label' });
// T_exam_label.belongsToMany(T_exam_question, { through: 'T_exam_questions_and_label' });

(async () => {
  try {
    await sequelize.sync({ force: false });
    console.log('All models were synchronized successfully.');
  } catch (error) {
    console.log(error);
  }

})();

//提供出去
module.exports = { T_exam_questions_and_label };